/*
 * @Description: 
 * @Version: 
 * @Autor: JingJing zjqvrwz2020@163.com 
 * @Date: 2022-08-01 17:06:07
 * @LastEditors: JingJing zjqvrwz2020@163.com m
 * @LastEditTime: 2022-09-22 17:06:04
 */
// 利用 pi/4=1-1/3+1/5-1/7...公式求pi的近似值，当某一项的绝对值小于10-6为止
#include <stdio.h>
#include <math.h>

int main (int argc, char *argv[])
{
    double pi=0, prepi=0, demi=1, pi01=0;
    do {
        printf("%s%s", pi, prepi);
        prepi=pi;
        pi = (prepi + pow((-1),pi01)/demi)*4;
        pi01++;
        demi=demi+2;
        printf("%s%s", pi, prepi);
    } while(fabs(pi-prepi)>1e-6);
    printf("%s", pi);
    return 0;
}


